package com.liqi.web.controller.dev;

import com.liqi.common.core.domain.R;
import com.liqi.dev.pojo.ReportDTO;
import com.liqi.web.service.dev.HomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api(tags = "首页管理")
@RequestMapping("/home")
@RestController
public class HomeController {

    @Autowired
    private HomeService homeService;

    @ApiOperation("已启用事项总数")
    @GetMapping("/serviceNum")
    public R<Integer> serviceNum() {
        return R.ok(homeService.serviceNum());
    }

    @ApiOperation("主题总数")
    @GetMapping("/subjectNum")
    public R<Integer> subjectNum() {
        return R.ok(homeService.subjectNum());
    }

    @ApiOperation("网点总数")
    @GetMapping("/branchNum")
    public R<Integer> branchNum() {
        return R.ok(homeService.branchNum());
    }

    @ApiOperation("已投放的设备总数")
    @GetMapping("/useDevNum")
    public R<Integer> useDevNum() {
        return R.ok(homeService.useDevNum());
    }

    @ApiOperation("设备总数")
    @GetMapping("/devNum")
    public R<Integer> devNum() {
        return R.ok(homeService.devNum());
    }

    @ApiOperation("模块总数")
    @GetMapping("/moduleNum")
    public R<Integer> moduleNum() {
        return R.ok(homeService.moduleNum());
    }

    @ApiOperation("事项点击次数top10")
    @GetMapping("/top10")
    public R<List<ReportDTO>> top10() {
        return R.ok(homeService.top10());
    }

    @ApiOperation("事项点击次数top10占比")
    @GetMapping("/top10Percent")
    public R<List<ReportDTO>> top10Percent() {
        return R.ok(homeService.top10Percent());
    }

    @ApiOperation("近30天异常上报数量趋势图")
    @GetMapping("/near30faultLog")
    public R<List<Map<String, Object>>> near30faultLog() {
        return R.ok(homeService.near30faultLog());
    }

}
